#@embedLayout()


#define content()

<form id="formId" method="post">
    <input type="hidden" name="tenant.tan_id" id="tanId" value="#(tenant.tanId??)">
    <table class="table table-bordered">
        <tr>
            <td style="padding-top:15px;">#(_res.get('tenant.form.tenantid')):</td>
            <td>
                <input type="text" id="tenantIdTxt" name="tenant.tenant_id" class="easyui-textbox" data-options="required:true,validType:{tenantName:''}" #if(tenant != null) readonly="readonly" #end value="#(tenant.tenant_id??)">
            </td>
        </tr>
        <tr>
            <td style="padding-top:15px;">#(_res.get('tenant.form.aliasname')):</td>
            <td>
                <input type="text" id="alias_name" name="tenant.alias_name" class="easyui-textbox" data-options="required:true,validType:{length:[1,64],spacing:''}" value="#(tenant.alias_name??)">
            </td>
        </tr>
    </table>
</form>

#end


#define css()


#end


#define js()

<script type="text/javascript">
    function datagrid_save(opr_type) {
        var url = '';
        if (opr_type == 'add') {
            url = contextRootPath + '/tenant/save';
        } else {
            url = contextRootPath + '/tenant/update';
        }

        $('#formId').form('submit', {
            url: url,
            onSubmit: function () {
                var flag = $(this).form('enableValidation').form('validate');
                if (flag) {
                    showProcess(true, '温馨提示', '正在提交数据...');
                }
                return flag;
            },
            success: function (data) {
                showProcess(false);

                data = eval('(' + data + ')');
                //在父窗口的渠道列表中添加新的渠道
                if (data.flag) {
                    var tenantId = $("#tenantIdTxt").textbox("getValue");
                    var aliasName = $("#alias_name").textbox("getValue");

                    top.$("#tenantMm").menu("appendItem", {
                        text: aliasName,
                        iconCls: 'icon-group',
                        onclick: function () {
                            changeTenant(tenantId);
                        }
                    });
                }

                var params = {};
                params.element = _datagrid;
                params.data = data;
                resultCallback(params);
            },
            onLoadError: function () {
                showProcess(false);
                $.messager.alert('温馨提示', '由于网络或服务器太忙，提交失败，请重试！');
            }
        });
    }

</script>

#end


